$(document)
		.ready(
				function() {

					// ---------------Dashboard Static charts----------//

					$(function() {
						$('#areachart')
								.highcharts(
										{
											chart : {
												type : 'area'
											},
											title : {
												text : ''
											},
											xAxis : {
												categories : [ '29-Oct',
														'28-Oct', '27-Oct',
														'24-Oct', '23-Oct',
														'22-Oct', '21-Oct',
														'20-Oct', '17-Oct',
														'16-Oct', '15-Oct',
														'14-Oct', '13-Oct',
														'10-Oct', '09-Oct',
														'08-Oct', '07-Oct',
														'06-Oct', '03-Oct',
														'02-Oct', '01-Oct',
														'30-Sep', '29-Sep',
														'27-Sep', '26-Sep',
														'25-Sep', '24-Sep',
														'23-Sep', '22-Sep',
														'21-Sep', '20-Sep',
														'17-Sep'/* ,'29-May','28-May','27-May','26-May','25-May','24-May','23-May','22-May','21-May','20-May','19-May','18-May','17-May','16-May','15-May','14-May','13-May','12-May','11-May','10-May','09-May','08-May','07-May','06-May','05-May','04-May','03-May','02-May','01-May','30-Apr','29-Apr','28-Apr','27-Apr','26-Apr','25-Apr','24-Apr','23-Apr','22-Apr','21-Apr','20-Apr','19-Apr','18-Apr','17-Apr','16-Apr','15-Apr','14-Apr','13-Apr','12-Apr','11-Apr','10-Apr','09-Apr','08-Apr','07-Apr','06-Apr','05-Apr','04-Apr','03-Apr','02-Apr','01-Apr','31-Mar','30-Mar','29-Mar','28-Mar','27-Mar','26-Mar','25-Mar','24-Mar','23-Mar','22-Mar','21-Mar','20-Mar','19-Mar','18-Mar','17-Mar','16-Mar','15-Mar','14-Mar','13-Mar','12-Mar','11-Mar','10-Mar','09-Mar','08-Mar','07-Mar','06-Mar','05-Mar','04-Mar','03-Mar','02-Mar','01-Mar','28-Feb','27-Feb','26-Feb','25-Feb','24-Feb','23-Feb','22-Feb','21-Feb','20-Feb','19-Feb','18-Feb','17-Feb','16-Feb','15-Feb','14-Feb','13-Feb','12-Feb','11-Feb','10-Feb','09-Feb','08-Feb','07-Feb','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','01-Jul','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','29-Jun','22-Jun','22-Jun','22-Jun','22-Jun','21-Jun','20-Jun','19-Jun','18-Jun','17-Jun','16-Jun','15-Jun','14-Jun','13-Jun','12-Jun','11-Jun','10-Jun','09-Jun','08-Jun','07-Jun','06-Jun','05-Jun','04-Jun','03-Jun','02-Jun','01-Jun','31-May','30-May','29-May','28-May','27-May','26-May','25-May','24-May','23-May','22-May','21-May','20-May','19-May','18-May','17-May','16-May','15-May','14-May','13-May','12-May','11-May','10-May','09-May','08-May','07-May','06-May','05-May','04-May','03-May','02-May','01-May','30-Apr','29-Apr','28-Apr','27-Apr','26-Apr','25-Apr','24-Apr','23-Apr','22-Apr','21-Apr','20-Apr','19-Apr','18-Apr','17-Apr','16-Apr','15-Apr','14-Apr','13-Apr','12-Apr','11-Apr','10-Apr','09-Apr','08-Apr','07-Apr','06-Apr','05-Apr','04-Apr','03-Apr','02-Apr','01-Apr','31-Mar','30-Mar','29-Mar','28-Mar','27-Mar','26-Mar','25-Mar','24-Mar','23-Mar','22-Mar','21-Mar','20-Mar','19-Mar','18-Mar','17-Mar','16-Mar','15-Mar','14-Mar','13-Mar','12-Mar','11-Mar','10-Mar','09-Mar','08-Mar','07-Mar','06-Mar','05-Mar','04-Mar','03-Mar','02-Mar','01-Mar','28-Feb','27-Feb','26-Feb','25-Feb','24-Feb','23-Feb','22-Feb','21-Feb','20-Feb','19-Feb','18-Feb','17-Feb','16-Feb','15-Feb','14-Feb','13-Feb','12-Feb','11-Feb','10-Feb','09-Feb','08-Feb','07-Feb','06-Feb','05-Feb','04-Feb','03-Feb','02-Feb','01-Feb','31-Jan','30-Jan','29-Jan','28-Jan','27-Jan','26-Jan','25-Jan','24-Jan','23-Jan','22-Jan','21-Jan','20-Jan','19-Jan','18-Jan','17-Jan','16-Jan','15-Jan','14-Jan','13-Jan','12-Jan','11-Jan','10-Jan','09-Jan','08-Jan','07-Jan','06-Jan','05-Jan','04-Jan','03-Jan','02-Jan','01-Jan','31-Dec','30-Dec','29-Dec','28-Dec','27-Dec','26-Dec','25-Dec','24-Dec','23-Dec','22-Dec','02-May','02-May','01-May','30-Apr','29-Apr','28-Apr','27-Apr','26-Apr','25-Apr','24-Apr','23-Apr','22-Apr','21-Apr','20-Apr','19-Apr','18-Apr','17-Apr','16-Apr','15-Apr','14-Apr','13-Apr','12-Apr','11-Apr','10-Apr','09-Apr','08-Apr','07-Apr','06-Apr','05-Apr','04-Apr','03-Apr','02-Apr','01-Apr','31-Mar','30-Mar','29-Mar','28-Mar','27-Mar','26-Mar','25-Mar','24-Mar','23-Mar','22-Mar','21-Mar','20-Mar','19-Mar','18-Mar','17-Mar','16-Mar','15-Mar','14-Mar','13-Mar','12-Mar','11-Mar','10-Mar','09-Mar','08-Mar','07-Mar','06-Mar','05-Mar','04-Mar','03-Mar','02-Mar','01-Mar','28-Feb','27-Feb','26-Feb','25-Feb','24-Feb','23-Feb','22-Feb','21-Feb','20-Feb','19-Feb','18-Feb','17-Feb','16-Feb','15-Feb','14-Feb','13-Feb','12-Feb','11-Feb','10-Feb','09-Feb','08-Feb','07-Feb','06-Feb','05-Feb','04-Feb','03-Feb','02-Feb','01-Feb','22-Jun','22-Jun','21-Jun','05-Jun','06-Jun','11-Jun','22-Jun','22-Jun','22-Jun','22-Jun' */]
											},
											credits : {
												enabled : false
											},
											series : [ {
												name : 'YTD P&L',
												data : [ -847, 479, 483, 485,
														486, 487, 489, 490,
														573, -1082, -1167,
														-1251, -1335, -1419,
														-1502, -1585, -1668,
														-1751, -1833, -1915,
														-1997, -2079, -2160,
														-2241, -1612, -1644,
														-2315, -2639, 2721,
														2625, -2703, -2869 /* ,-2947,-3024,-3101,-3295,-3378,3457,1579,1581,1588,1595,1602,1609,1617,17890,17350,16826,8157,15815,7662,111313,11493,13896,6716,9080,3754,12062,5806,7816,3216,10279,4919,6580,2689,17058,4048,2299,2893,3401,1912,2378,2758,1527,1866,2119,1144,1356,1483,763,849,850,383,343,218,5,-161,8,131,343,-3672,-2321,-3251,-4260,-2673,-3720,-4845,-3023,-4186,-5425,-3370,-4647,-6000,-3714,-5103,-6567,-4053,-5553,-7126,-4386,-5994,-7674,-4712,-6425,-8207,-5028,-6841,-8719,-5330,-7235,-9201,-5612,-7599,-9639,-5862,-7915,-10006,6280,-59087,-75683,-46505,-63468,-81163,-49796,-67859,-86655,-53092,-72256,-92154,-56393,69315,88499,11784,15882,14653,8932,-12094,-15347,-9344,-12640,-16024,-9748,-13174,-16689,-10145,-13702,-17345,-21875,-7300,-13200,151,-12530,-7300,-52,-63,-78,-94,-111,-131,-152,-175,-199,-227,-256,-288,-323,-361,-19,2,23,32,42,215,0,10,18,26,35,45,54,64,74,-298,0,-59,-1,-3,-3,-3,-3,-3,-2,-2,-2,6,5,5,5,5,5,5,4,4,4,4,3,-49,-54,-58,-64,-69,-75,-82,-1,-2,-4,-5,-7,-9,-11,-14,-16,-19,-22,-25,-28,-32,-36,-40,-45,-50,-55,-61,-67,-73,552,6,11,10,10,10,10,10,10,10,10,10,9,9,9,9,9,8,8,8,7,-5,-5,-5,-4,-4,-3,-3,-2,-2,-1,0,18270,1408,-1675,25,-3,0,0,1,2,3,4,5,6,7,8,9,10,12,13,15,17,19,21,23,25,28,31,34,37,40,44,48,52,-463,-6,-286,-275,-260,-245,-230,-216,-203,-189,-176,-164,-150,-137,-124,-112,-101,-90,-80,-70,-61,-52,-44,-36,-29,-22,-16,-10,-4,1,6,11,16,20,24,28,32,35,38,42,45,48,50,53,56,58,61,63,66,68,71,73,76,78,81,83,86,88,91,94,97,100,103,106,110,113,117,121,125,129,133,138,142,147,153,158,-1082,170,176,182,189,196,203,211,219,227,236,-243,-262,-283,-306,-330,-357,-385,-416,-450,-486,-525,-567,-612,-78,55,56,51,47,42,38,33,29,25,20,16,12,8,362,,-,,,,32,58,-46267,-3917,-2084,-1418,-1065,-840,-13225,-6352,-4174,-3091,-2435,-1990,-1666,-1416,-1218,-1054,-917,-800,-6572,-5327,-4439,-3770,2032,1973,1775,1618,-2503,-2572,-2638,-2705,-2773,-2841,-2909,-1011,-946,-1000,-1055,-1111,-1167,-1224,-1281,-1338,-1397,-5197,-5273,-5350,-5428,-5506,-5585,-5664,-5743,-5823,-5904,-5985,-6066,-6148,-5973,-1547,-6392,-6481,-6565,-6650,-6735,-6821,-6908,-6995,-7082,-7170,-7258,-7347,-7436,-7526,-7616,-7707,28404,36393,43643,-110261,-148494,-187465,-113588,-152929,-193010,18423,23086,27009,15097,-161801,21465,11770,14215,15920,8443,9779,-733688,5116,5343,4831 */
												]
											} ]
										});
					});
					// ---------Dashboard Static charts End here--------------//
					// prepare the data
					var source = {
						dataType : "csv",
						dataFields : [ {
							name : 'Fund',
							type : 'string'
						}, {
							name : 'Strategy',
							type : 'string'
						}, {
							name : 'secType',
							type : 'string'
						}, {
							name : 'Counterparty',
							type : 'string'
						}, {
							name : 'Curr',
							type : 'string'
						}, {
							name : 'Sec_Type',
							type : 'string'
						}, {
							name : 'Trade_Date',
							type : 'string'
						}, {
							name : 'Confirmed',
							type : 'string'
						}, {
							name : 'Quantity',
							type : 'string'
						}, {
							name : 'Cost_Price',
							type : 'string'
						}, {
							name : 'Cost',
							type : 'string'
						}, {
							name : 'Price',
							type : 'string'
						}, {
							name : 'MV',
							type : 'string'
						}, {
							name : 'PL_Today',
							type : 'string'
						}, {
							name : 'MTD_PL',
							type : 'string'
						}, {
							name : 'YTD_PL',
							type : 'string'
						}, {
							name : 'PL',
							type : 'string'
						}

						],
						url : 'assets/sampledata/P-LReport.csv'
					};
					var dataAdapter = new $.jqx.dataAdapter(source, {
						loadComplete : function() {
							// data is loaded.
						}
					});
					var cellClass = function(row, dataField, cellText, rowData) {
						var cellValue = rowData[dataField];
						switch (dataField) {
						case "diffQuantity":
							if (cellValue > 100 || cellValue < 0) {
								return "minavg";
							}
							if (cellValue <= 100) {
								return "max";
							}
							return "max";

						case "diffMarketValue":
							if (cellValue > 100 || cellValue < 0) {
								return "minavg";
							}
							if (cellValue <= 100) {
								return "max";
							}
							return "min";
						}
					};
					// create jqxDataTable.
					$("#ProfitLoss").jqxGrid({
						source : dataAdapter,
						altRows : true,
						width : '99%',
						height : '600',
						sortable : true,
						pageable : false,
						filterable : true,
						groupable : true,
						showstatusbar : true,
						statusbarheight : 50,
						showaggregates : true,
						columnsresize : true,
						columnsreorder : true,

						columns : [ {
							text : 'Fund',
							cellsAlign : 'center',
							columngroup : 'ProductDetails',
							align : 'center',
							dataField : 'Fund',/* pinned: true,*/
							width : '10%',
							minWidth : 80,
							pinned : true
						}, {
							text : 'Strategy',
							cellsAlign : 'center',
							columngroup : 'ProductDetails',
							align : 'center',
							dataField : 'Strategy',
							width : '10%',
							pinned : true
						}, {
							text : 'Investment ID',
							dataField : 'secType',
							columngroup : 'ProductDetails',
							cellsformat : 'c2',
							align : 'center',
							cellsAlign : 'center',
							width : '10%',
							pinned : true
						}, {
							text : 'Counterparty / Custodian',
							columngroup : 'ProductDetails',
							dataField : 'Counterparty',
							cellsformat : 'd',
							cellsAlign : 'center',
							align : 'center',
							width : '10%',
							minWidth : 180
						}, {
							text : 'Curr',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Curr',
							width : '10%'
						}, {
							text : 'Sec Type',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Sec_Type',
							width : '10%'
						}, {
							text : 'Trade Date',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Trade_Date',
							width : '10%'
						}, {
							text : 'Confirmed: Y/N',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Confirmed',
							width : '10%'
						}, {
							text : 'Quantity',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Quantity',
							width : '10%'
						}, {
							text : 'Cost Price',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Cost_Price',
							width : '10%',
							aggregates : [ 'sum' ]
						}, {
							text : 'Cost',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Cost',
							width : '10%',
							aggregates : [ 'sum' ]
						}, {
							text : 'Price',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'Price',
							width : '10%',
							aggregates : [ 'sum' ]
						}, {
							text : 'MV',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'MV',
							width : '10%'
						}, {
							text : 'P&L Today',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'PL_Today',
							width : '10%'
						}, {
							text : 'MTD P&L',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'MTD_PL',
							width : '10%',
							aggregates : [ 'sum' ]
						}, {
							text : 'YTD P&L',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'YTD_PL',
							width : '10%',
							aggregates : [ 'sum' ]
						}, {
							text : 'P&L (since TD)',
							cellsAlign : 'center',
							align : 'center',
							dataField : 'PL',
							width : '10%'
						} ]

					});
				});